package cn.itcast.core.service;

import cn.itcast.core.pojo.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @auther :hyh
 * @desc :
 * @date :2019/5/12
 */
//@Component   //必须加上。
public class DeptClientServiceFallBackFactory implements FallbackFactory<DeptClientService> {
    @Override
    public DeptClientService create(Throwable throwable) {
        return new DeptClientService() {
            @Override
            public List<Dept> list() {
                List<Dept> objects = new ArrayList<>();
                objects.add(new Dept().setDname("12W  我给不起啊。。。。"));
                return objects;
            }

            @Override
            public Dept get(Long id) {

                return new Dept().setDname("熔断器启动了。。。。。");
            }

            @Override
            public boolean add(Dept dept) {
                return false;
            }
        };
    }
}
